﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using DTO;
using DataService;

public partial class UserControls_ContactControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ddlTypeBilling.DataSource = (new ContactService()).GetContactTypes();
            DataBind();
        }
    }

    public Contact Contact
    {
        set
        {            
            PersonControl1.Person = value;
            ddlTypeBilling.SelectedValue = value.Type.Id.ToString();
        }
        get
        {
            Contact contact = ( Contact ) PersonControl1.Person;
            contact.Type = new Contact.ContactType(Convert.ToInt32(ddlTypeBilling.SelectedValue))
            {
                Name = ddlTypeBilling.Text
            };
            return contact;
        }
    }
}